/*
 * Package il.ac.biu.cs.grossmm.api.data
 * File PersistentPointManager.java
 * 
 * This is a part of presence service framework API. 
 * See javadoc for more information.
 *  
 * Copyright (C) 2006 Grossmann Mark
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
 * MA  02110-1301, USA.
 */

package il.ac.biu.cs.grossmm.api.flow;

import il.ac.biu.cs.grossmm.api.OperationFailedException;
import il.ac.biu.cs.grossmm.api.data.NodeType;
import il.ac.biu.cs.grossmm.api.keys.KeyPattern;

/**
 * SPI to support pluggable persistent publication points
 */
public interface PersistentPointManager {

	/**
	 * Creates a new persistent publication point
	 * 
	 * @param <N>
	 *            node type class for the publication point
	 * @param pattern
	 *            key pattern for the publication point
	 * @param nodeType
	 *            data node type for the publication point
	 * @param name
	 *            unique identifier for the publication point
	 * @return the publication point
	 * @throws OperationFailedException
	 *             when operation failed
	 */
	public abstract <N> PublicationPointBase<N> create(KeyPattern pattern,
		NodeType<N> nodeType, String name) throws OperationFailedException;

	/**
	 * Gets existing persistent publication point
	 * 
	 * @param <N>
	 *            node type class for the publication point
	 * @param name
	 *            unique identifier for the publication point
	 * @return the publication point
	 * @throws OperationFailedException
	 *             when operation failed
	 */
	public abstract <N> PublicationPointBase<N> get(String name)
		throws OperationFailedException;

	/**
	 * Removes an existing persistent pubication point
	 * 
	 * @param name
	 *            unique identifier for the publication point
	 * @return true if the point has been removed, false if no such point
	 *         existed
	 * @throws OperationFailedException
	 *             when operation failed
	 */
	public abstract boolean remove(String name) throws OperationFailedException;

	/**
	 * Queries whether peristsent publication point with a given identifier
	 * exists
	 * 
	 * @param identifier
	 *            unique identifier for the publication point
	 * @return true peristsent publication point with a given identifier exists,
	 *         false if it does not exist
	 * @throws OperationFailedException
	 *             when operation failed
	 */
	public abstract boolean pointExists(String identifier)
		throws OperationFailedException;

	/**
	 * Queries whether peristsent publication point with a given key pattern
	 * exists
	 * 
	 * @param pnp
	 *            the key pattern
	 * @return true if peristsent publication point with a given key pattern
	 *         exists, false if it does not exist
	 * @throws OperationFailedException
	 *             when operation failed
	 */
	public abstract boolean pointExists(KeyPattern pnp)
		throws OperationFailedException;
}
